package com.qingcloud.adminbackend.enums;

/**
 * 数据源类型枚举
 *
 * @author wangjinnan
 */
public enum DatabaseTypeEnum {

    MYSQL(1, "MySql", "com.mysql.cj.jdbc.Driver"),
    PGSQL(2, "PostgreSql", "org.postgresql.Driver"),
    ORACLE(3, "Oracle", "oracle.jdbc.driver.OracleDriver"),
    SQL_SERVER(4, "SqlServer", "com.microsoft.sqlserver.jdbc.SQLServerDriver");

    public Integer code;

    public String title;

    public String driver;

    DatabaseTypeEnum(Integer code, String title, String driver) {
        this.code = code;
        this.title = title;
        this.driver = driver;
    }

    public static DatabaseTypeEnum getByCode(Integer code) {
        DatabaseTypeEnum[] uss = values();
        for (DatabaseTypeEnum us : uss) {
            if (us.code.equals(code)) {
                return us;
            }
        }
        return DatabaseTypeEnum.MYSQL;
    }
}
